package com.dob.dbo.jdbc;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
public class JDBCTemplateExample {

	
		@Autowired
		private DataSource dataSource;
		private JdbcTemplate jdbcTemplate;

		public DataSource getDataSource() {
			return dataSource;
		}

		public void setDataSource(DataSource dataSource) {
			this.dataSource = dataSource;
			this.jdbcTemplate= new JdbcTemplate(dataSource);
		}
		
		public void getEmployeeCount(){
			
			String sql="SELECT count(*) FROM EMPLOYEE ";
			System.out.println(jdbcTemplate.queryForInt(sql));
			
		}
		
		public void getEmployeeName(int empId){
			String sql="SELECT EMPNAME FROm EMPLOYEE WHERE EMPID=?";
			System.out.println(jdbcTemplate.queryForObject(sql, new Object[]{empId}, String.class));
		}
		
}

